<template>
	<div class="w-100">
		<div class="tabs-content" v-if="!showResult">
			<el-scrollbar max-height="80vh">
				<BaseInfo ref="formRef" v-if="active == 1" v-bind="$attrs" @submit="onChange"></BaseInfo>
				<Extend ref="formRef" v-if="active == 2" v-bind="$attrs" @submit="onChange"></Extend>
			</el-scrollbar>
			<div class="fc">
				<el-button class="ap-btn" type="primary" @click="handleSubmit('submit')"> 提交保存 </el-button>
			</div>
		</div>
		<DataGather
			v-else
			changeType="居家从业人员"
			:dataType="5"
			:name="nowData.practitionersName"
			:active="active"
			@backNext="handleBack('next')"
			@back="handleBack"
			@init="getInitMod"
		>
		</DataGather>
	</div>
</template>

<script setup lang="ts">
import BaseInfo from './BaseInfo/index.vue'
import Extend from './Extend/index.vue'
import DataGather from '@/views/datacenter/components/DataGather/change/index.vue'
import { useCommonStore } from '@/stores/common'

const { tempNowObj } = storeToRefs(useCommonStore())
const emit = defineEmits(['refresh'])

const formRef = ref(null)
const active: any = ref(tempNowObj.value?.active || 1)
const showResult = ref(false)

const nowData = ref({
	practitionersName: tempNowObj.value?.name,
})
const getInitMod = () => {
	showResult.value = false
}
const onChange = (data) => {
	showResult.value = true
}
const handleSubmit = (type) => {
	formRef.value!.onSave()
}
const handleBack = (type?: string) => {
	showResult.value = false
	if (type) emit('refresh')
}
</script>

<style scoped lang="scss"></style>
